package com.kb.service.impl;

import cn.iocoder.yudao.module.system.api.category.CategoryApi;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kb.entity.ViewPreviewData;
import com.kb.mapper.mysql.ViewPreviewDataMapper;
import com.kb.service.ViewPreviewDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;

@DS("master")
@Service
@Slf4j
public class ViewPreviewDataServiceImpl extends ServiceImpl<ViewPreviewDataMapper, ViewPreviewData> implements ViewPreviewDataService {


    @Resource
    private ViewPreviewDataMapper viewPreviewDataMapper;


    @Override
    public boolean recordCallNumber(String partNumber,String source) {
        ViewPreviewData viewPreviewData = new ViewPreviewData();
        viewPreviewData.setPartNumber(partNumber);
        viewPreviewData.setSysSource("other");
        if (source != null){
            viewPreviewData.setSysSource(source);
        }
        viewPreviewData.setAccessTime(LocalDateTime.now());
        return viewPreviewDataMapper.insert(viewPreviewData) > 0;
    }

}
